package com.zyz.sunliky.quartz.jobs;

import com.zyz.sunliky.quartz.ScheduledJob;
import com.zyz.sunliky.service.SupplierService;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * 项目进度汇报自动推送
 */
@Component
public class ProjectJob extends ScheduledJob {



    @Autowired  // 加上@Autowired注解

    SupplierService supplierService;


    @Override
    // 每两个小时执行一次
//    public String getCron() {
//        return "0 */2 * * * ?";
//    }
//    public String getCron() {
//        return "0 */5 * * * ?";
//    }
    // 每天下午5点执行一
    public String getCron() {
        return "0 0 17 * * ?";
    }
    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        try {
            Date now = new Date();
            System.out.println("项目进度汇报自动推送开始---" + now);
            supplierService.saveRreport();
            Date now1 = new Date();
            System.out.println("项目进度汇报自动推送结束---" + now1);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}


